package com.cheng.io.print;

import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.Date;

/**
 * 打印流（字节形式）
 * 支持自动刷新流、自动换行println()、字符串转义print("\n")、格式化输出
 * 构造器：PrintStream(String fileName) | PrintStream(OutputStream out)
 */
public class PrintStreamTest01 {
    public static void main(String[] args) {
        try (
                PrintStream printStream = new PrintStream("io/resources/log");
        ) {
            printStream.println(100);
            printStream.println(true);
            printStream.println("100");
            printStream.println("\"Hello World\"");


            String name = "张三";
            int age = 20;
            // %s字符串 %d整数 %f小数（%.2f保留两位小数）%c表示字符
            printStream.printf("name:%s,age:%d",name,age);
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
}
